package com.cal.utms.entity;

import java.io.Serializable;

import javax.persistence.*;

@Entity
@Table(name = "user_group_to_menu", uniqueConstraints = @UniqueConstraint(columnNames = { "MENU_ID", "USER_GROUP_ID" }))
public class UserToMenu implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private UserToMenuId userToMenuId;
	private MenuScreen menuScreen;
	private UserGroup userGroup;

	public UserToMenu() {

	}

	public UserToMenu(UserToMenuId userToMenuId, MenuScreen menuScreen, UserGroup userGroup) {
		super();
		this.userToMenuId = userToMenuId;
		this.menuScreen = menuScreen;
		this.userGroup = userGroup;
	}

	@EmbeddedId
	@AttributeOverrides({ @AttributeOverride(name = "menuId", column = @Column(name = "MENU_ID", nullable = false)),
			@AttributeOverride(name = "grpId", column = @Column(name = "USER_GROUP_ID", nullable = false)) })
	public UserToMenuId getUserToMenuId() {
		return userToMenuId;
	}

	public void setUserToMenuId(UserToMenuId userToMenuId) {
		this.userToMenuId = userToMenuId;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "MENU_ID", nullable = false, insertable = false, updatable = false)
	public MenuScreen getMenuScreen() {
		return menuScreen;
	}

	public void setMenuScreen(MenuScreen menuScreen) {
		this.menuScreen = menuScreen;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "USER_GROUP_ID", nullable = false, insertable = false, updatable = false)
	public UserGroup getUserGroup() {
		return userGroup;
	}

	public void setUserGroup(UserGroup userGroup) {
		this.userGroup = userGroup;
	}

}
